import React, {Component} from 'react';

import {withRouter} from 'react-router-dom'

class Header extends Component {

    back=()=>{
       this.props.history.goBack()
    }
    forword=()=>{
        this.props.history.goForward()
    }

    render() {
        console.log(this.props)
        return (
            <div className="row">
                <div className="col-xs-offset-2 col-xs-8">
                    <div className="page-header"><h2>React Router Demo</h2></div>
                </div>
                <div>
                    <button onClick={this.back}>back</button>
                    <button onClick={this.forword}>forWord</button>
                </div>
            </div>
        );
    }
}

export default withRouter(Header);

//withRouter可以加工一般组件，让一般组件具备路由组件所特有的API
//withRouter的返回值是一个新组件